
var moment = require("moment");             //JavaScript 日期处理类库
//签到验证
app.post("/sign", function (req, res, signStartTime) {
    var param = req.body;
    //签到状态 0为旷课，1为正常 ，2为迟到
    var signStat = 0;
    var signStartTime;
    var beLateTime;
    var beMissTime;
    //获取标准日期;
    var myDate = new Date();
    console.log("myDate: " + myDate);
    var mySignDate = moment(new Date().getTime()).format('YYYY-MM-DD HH:mm:ss');
    console.log("mySignDate: " + mySignDate);

    var mySignDate = moment().locale('zh-cn').format('YYYY-MM-DD HH:mm:ss');
    var duration = moment
        .duration(mySignDate.diff(signStartTime))
        .asSeconds();
    if (duration < beLateTime) { signStat = '1'; }
    else if (duration < beMissTime) { signStat = '2'; }
    db.all("INSERT INTO tb_Sign (stuID, SignTime,SignStat) VALUES (?,?,?)", [param.stuID, mySignDate, signStat], function (err) {
        //插入成功返回给用户；
        if (!err) {
            res.send({ msg: "success" });
        }
        else {
            res.send({ msg: "failed" });
        }
    })
})